

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>Cache pool &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="如何配置好 Ceph Kerberos 认证的详细文档" href="../ceph_krb_auth/" />
    <link rel="prev" title="BlueStore Internals" href="../bluestore/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../internals/">Ceph 内幕</a> &raquo;</li>
        
      <li>Cache pool</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/dev/cache-pool.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../developer_guide/">开发者指南</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../internals/">Ceph 内幕</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../blkin/">Tracing Ceph With LTTng</a></li>
<li class="toctree-l2"><a class="reference internal" href="../blkin/#tracing-ceph-with-blkin">Tracing Ceph With Blkin</a></li>
<li class="toctree-l2"><a class="reference internal" href="../bluestore/">BlueStore Internals</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Cache pool</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#purpose">Purpose</a></li>
<li class="toctree-l3"><a class="reference internal" href="#use-cases">Use cases</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#read-write-pool-writeback">Read-write pool, writeback</a></li>
<li class="toctree-l4"><a class="reference internal" href="#read-only-pool-weak-consistency">Read-only pool, weak consistency</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#interface">Interface</a></li>
<li class="toctree-l3"><a class="reference internal" href="#tiering-agent">Tiering agent</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#hitset-metadata">HitSet metadata</a></li>
<li class="toctree-l4"><a class="reference internal" href="#cache-mode">Cache mode</a></li>
<li class="toctree-l4"><a class="reference internal" href="#cache-sizing">Cache sizing</a></li>
<li class="toctree-l4"><a class="reference internal" href="#other-tunables">Other tunables</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../ceph_krb_auth/">如何配置好 Ceph Kerberos 认证的详细文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-mirroring/">CephFS Mirroring</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-reclaim/">CephFS Reclaim Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-snapshots/">CephFS 快照</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephx/">Cephx</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephx_protocol/">Cephx 认证协议详细阐述</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config/">配置管理系统</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config-key/">config-key layout</a></li>
<li class="toctree-l2"><a class="reference internal" href="../context/">CephContext</a></li>
<li class="toctree-l2"><a class="reference internal" href="../continuous-integration/">Continuous Integration Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../corpus/">资料库结构</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cpu-profiler/">Oprofile 的安装</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cxx/">C++17 and libstdc++ ABI</a></li>
<li class="toctree-l2"><a class="reference internal" href="../deduplication/">去重</a></li>
<li class="toctree-l2"><a class="reference internal" href="../delayed-delete/">CephFS delayed deletion</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev_cluster_deployement/">开发集群的部署</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev_cluster_deployement/#id5">在同一机器上部署多套开发集群</a></li>
<li class="toctree-l2"><a class="reference internal" href="../development-workflow/">开发流程</a></li>
<li class="toctree-l2"><a class="reference internal" href="../documenting/">为 Ceph 写作文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../encoding/">序列化（编码、解码）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../erasure-coded-pool/">纠删码存储池</a></li>
<li class="toctree-l2"><a class="reference internal" href="../file-striping/">File striping</a></li>
<li class="toctree-l2"><a class="reference internal" href="../freebsd/">FreeBSD Implementation details</a></li>
<li class="toctree-l2"><a class="reference internal" href="../generatedocs/">Ceph 文档的构建</a></li>
<li class="toctree-l2"><a class="reference internal" href="../health-reports/">Health Reports</a></li>
<li class="toctree-l2"><a class="reference internal" href="../iana/">IANA 号</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kubernetes/">Hacking on Ceph in Kubernetes with Rook</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libs/">库体系结构</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logging/">集群日志的用法</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logs/">调试日志</a></li>
<li class="toctree-l2"><a class="reference internal" href="../macos/">在 MacOS 上构建</a></li>
<li class="toctree-l2"><a class="reference internal" href="../messenger/">Messenger notes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-bootstrap/">Monitor bootstrap</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-elections/">Monitor Elections</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-on-disk-formats/">ON-DISK FORMAT</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-osdmap-prune/">FULL OSDMAP VERSION PRUNING</a></li>
<li class="toctree-l2"><a class="reference internal" href="../msgr2/">msgr2 协议（ msgr2.0 和 msgr2.1 ）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../network-encoding/">Network Encoding</a></li>
<li class="toctree-l2"><a class="reference internal" href="../network-protocol/">网络协议</a></li>
<li class="toctree-l2"><a class="reference internal" href="../object-store/">对象存储架构概述</a></li>
<li class="toctree-l2"><a class="reference internal" href="../osd-class-path/">OSD class path issues</a></li>
<li class="toctree-l2"><a class="reference internal" href="../peering/">互联</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf/">Using perf</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf_counters/">性能计数器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf_histograms/">Perf histograms</a></li>
<li class="toctree-l2"><a class="reference internal" href="../placement-group/">PG （归置组）说明</a></li>
<li class="toctree-l2"><a class="reference internal" href="../quick_guide/">开发者指南（快速）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rados-client-protocol/">RADOS 客户端协议</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-diff/">RBD 增量备份</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-export/">RBD Export &amp; Import</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-layering/">RBD Layering</a></li>
<li class="toctree-l2"><a class="reference internal" href="../release-checklists/">Release checklists</a></li>
<li class="toctree-l2"><a class="reference internal" href="../release-process/">Ceph Release Process</a></li>
<li class="toctree-l2"><a class="reference internal" href="../seastore/">SeaStore</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sepia/">Sepia 社区测试实验室</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session_authentication/">Session Authentication for the Cephx Protocol</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/">测试笔记</a></li>
<li class="toctree-l2"><a class="reference internal" href="../versions/">Public OSD Version</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vstart-ganesha/">NFS CephFS-RGW Developer Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../wireshark/">Wireshark Dissector</a></li>
<li class="toctree-l2"><a class="reference internal" href="../zoned-storage/">Zoned Storage Support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../osd_internals/">OSD 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mds_internals/">MDS 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../radosgw/">RADOS 网关开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ceph-volume/">ceph-volume 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../crimson/">Crimson developer documentation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="cache-pool">
<h1>Cache pool<a class="headerlink" href="#cache-pool" title="Permalink to this headline">¶</a></h1>
<div class="section" id="purpose">
<h2>Purpose<a class="headerlink" href="#purpose" title="Permalink to this headline">¶</a></h2>
<p>Use a pool of fast storage devices (probably SSDs) and use it as a
cache for an existing slower and larger pool.</p>
<p>Use a replicated pool as a front-end to service most I/O, and destage
cold data to a separate erasure coded pool that does not currently (and
cannot efficiently) handle the workload.</p>
<p>We should be able to create and add a cache pool to an existing pool
of data, and later remove it, without disrupting service or migrating
data around.</p>
</div>
<div class="section" id="use-cases">
<h2>Use cases<a class="headerlink" href="#use-cases" title="Permalink to this headline">¶</a></h2>
<div class="section" id="read-write-pool-writeback">
<h3>Read-write pool, writeback<a class="headerlink" href="#read-write-pool-writeback" title="Permalink to this headline">¶</a></h3>
<p>We have an existing data pool and put a fast cache pool “in front” of
it.  Writes will go to the cache pool and immediately ack.  We flush
them back to the data pool based on the defined policy.</p>
</div>
<div class="section" id="read-only-pool-weak-consistency">
<h3>Read-only pool, weak consistency<a class="headerlink" href="#read-only-pool-weak-consistency" title="Permalink to this headline">¶</a></h3>
<p>We have an existing data pool and add one or more read-only cache
pools.  We copy data to the cache pool(s) on read.  Writes are
forwarded to the original data pool.  Stale data is expired from the
cache pools based on the defined policy.</p>
<p>This is likely only useful for specific applications with specific
data access patterns.  It may be a match for rgw, for example.</p>
</div>
</div>
<div class="section" id="interface">
<h2>Interface<a class="headerlink" href="#interface" title="Permalink to this headline">¶</a></h2>
<p>Set up a read/write cache pool foo-hot for pool foo:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">add</span> <span class="n">foo</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">cache</span><span class="o">-</span><span class="n">mode</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">writeback</span>
</pre></div>
</div>
<p>Direct all traffic for foo to foo-hot:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="nb">set</span><span class="o">-</span><span class="n">overlay</span> <span class="n">foo</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span>
</pre></div>
</div>
<p>Set the target size and enable the tiering agent for foo-hot:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">hit_set_type</span> <span class="n">bloom</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">hit_set_count</span> <span class="mi">1</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">hit_set_period</span> <span class="mi">3600</span>   <span class="c1"># 1 hour</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">target_max_bytes</span> <span class="mi">1000000000000</span>  <span class="c1"># 1 TB</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">min_read_recency_for_promote</span> <span class="mi">1</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">min_write_recency_for_promote</span> <span class="mi">1</span>
</pre></div>
</div>
<p>Drain the cache in preparation for turning it off:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">cache</span><span class="o">-</span><span class="n">mode</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">forward</span>
<span class="n">rados</span> <span class="o">-</span><span class="n">p</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">cache</span><span class="o">-</span><span class="n">flush</span><span class="o">-</span><span class="n">evict</span><span class="o">-</span><span class="nb">all</span>
</pre></div>
</div>
<p>When cache pool is finally empty, disable it:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">remove</span><span class="o">-</span><span class="n">overlay</span> <span class="n">foo</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">remove</span> <span class="n">foo</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span>
</pre></div>
</div>
<p>Read-only pools with lazy consistency:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">add</span> <span class="n">foo</span> <span class="n">foo</span><span class="o">-</span><span class="n">east</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">cache</span><span class="o">-</span><span class="n">mode</span> <span class="n">foo</span><span class="o">-</span><span class="n">east</span> <span class="n">readonly</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">add</span> <span class="n">foo</span> <span class="n">foo</span><span class="o">-</span><span class="n">west</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">tier</span> <span class="n">cache</span><span class="o">-</span><span class="n">mode</span> <span class="n">foo</span><span class="o">-</span><span class="n">west</span> <span class="n">readonly</span>
</pre></div>
</div>
</div>
<div class="section" id="tiering-agent">
<h2>Tiering agent<a class="headerlink" href="#tiering-agent" title="Permalink to this headline">¶</a></h2>
<p>The tiering policy is defined as properties on the cache pool itself.</p>
<div class="section" id="hitset-metadata">
<h3>HitSet metadata<a class="headerlink" href="#hitset-metadata" title="Permalink to this headline">¶</a></h3>
<p>First, the agent requires HitSet information to be tracked on the
cache pool in order to determine which objects in the pool are being
accessed.  This is enabled with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">hit_set_type</span> <span class="n">bloom</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">hit_set_count</span> <span class="mi">1</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">hit_set_period</span> <span class="mi">3600</span>   <span class="c1"># 1 hour</span>
</pre></div>
</div>
<p>The supported HitSet types include ‘bloom’ (a bloom filter, the
default), ‘explicit_hash’, and ‘explicit_object’.  The latter two
explicitly enumerate accessed objects and are less memory efficient.
They are there primarily for debugging and to demonstrate pluggability
for the infrastructure.  For the bloom filter type, you can additionally
define the false positive probability for the bloom filter (default is 0.05):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">hit_set_fpp</span> <span class="mf">0.15</span>
</pre></div>
</div>
<p>The hit_set_count and hit_set_period define how much time each HitSet
should cover, and how many such HitSets to store.  Binning accesses
over time allows Ceph to independently determine whether an object was
accessed at least once and whether it was accessed more than once over
some time period (“age” vs “temperature”).</p>
<p>The <code class="docutils literal notranslate"><span class="pre">min_read_recency_for_promote</span></code> defines how many HitSets to check for the
existence of an object when handling a read operation. The checking result is
used to decide whether to promote the object asynchronously. Its value should be
between 0 and <code class="docutils literal notranslate"><span class="pre">hit_set_count</span></code>. If it’s set to 0, the object is always promoted.
If it’s set to 1, the current HitSet is checked. And if this object is in the
current HitSet, it’s promoted. Otherwise not. For the other values, the exact
number of archive HitSets are checked. The object is promoted if the object is
found in any of the most recent <code class="docutils literal notranslate"><span class="pre">min_read_recency_for_promote</span></code> HitSets.</p>
<p>A similar parameter can be set for the write operation, which is
<code class="docutils literal notranslate"><span class="pre">min_write_recency_for_promote</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="p">{</span><span class="n">cachepool</span><span class="p">}</span> <span class="n">min_read_recency_for_promote</span> <span class="mi">1</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="p">{</span><span class="n">cachepool</span><span class="p">}</span> <span class="n">min_write_recency_for_promote</span> <span class="mi">1</span>
</pre></div>
</div>
<p>Note that the longer the <code class="docutils literal notranslate"><span class="pre">hit_set_period</span></code> and the higher the
<code class="docutils literal notranslate"><span class="pre">min_read_recency_for_promote</span></code>/<code class="docutils literal notranslate"><span class="pre">min_write_recency_for_promote</span></code> the more RAM
will be consumed by the ceph-osd process. In particular, when the agent is active
to flush or evict cache objects, all hit_set_count HitSets are loaded into RAM.</p>
</div>
<div class="section" id="cache-mode">
<h3>Cache mode<a class="headerlink" href="#cache-mode" title="Permalink to this headline">¶</a></h3>
<p>The most important policy is the cache mode:</p>
<blockquote>
<div><p>ceph osd pool set foo-hot cache-mode writeback</p>
</div></blockquote>
<p>The supported modes are ‘none’, ‘writeback’, ‘forward’, and
‘readonly’.  Most installations want ‘writeback’, which will write
into the cache tier and only later flush updates back to the base
tier.  Similarly, any object that is read will be promoted into the
cache tier.</p>
<p>The ‘forward’ mode is intended for when the cache is being disabled
and needs to be drained.  No new objects will be promoted or written
to the cache pool unless they are already present.  A background
operation can then do something like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">rados</span> <span class="o">-</span><span class="n">p</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">cache</span><span class="o">-</span><span class="k">try</span><span class="o">-</span><span class="n">flush</span><span class="o">-</span><span class="n">evict</span><span class="o">-</span><span class="nb">all</span>
<span class="n">rados</span> <span class="o">-</span><span class="n">p</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">cache</span><span class="o">-</span><span class="n">flush</span><span class="o">-</span><span class="n">evict</span><span class="o">-</span><span class="nb">all</span>
</pre></div>
</div>
<p>to force all data to be flushed back to the base tier.</p>
<p>The ‘readonly’ mode is intended for read-only workloads that do not
require consistency to be enforced by the storage system.  Writes will
be forwarded to the base tier, but objects that are read will get
promoted to the cache.  No attempt is made by Ceph to ensure that the
contents of the cache tier(s) are consistent in the presence of object
updates.</p>
</div>
<div class="section" id="cache-sizing">
<h3>Cache sizing<a class="headerlink" href="#cache-sizing" title="Permalink to this headline">¶</a></h3>
<p>The agent performs two basic functions: flushing (writing ‘dirty’
cache objects back to the base tier) and evicting (removing cold and
clean objects from the cache).</p>
<p>The thresholds at which Ceph will flush or evict objects is specified
relative to a ‘target size’ of the pool.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">cache_target_dirty_ratio</span> <span class="mf">.4</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">cache_target_dirty_high_ratio</span> <span class="mf">.6</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">cache_target_full_ratio</span> <span class="mf">.8</span>
</pre></div>
</div>
<p>will begin flushing dirty objects when 40% of the pool is dirty and begin
evicting clean objects when we reach 80% of the target size.</p>
<p>The target size can be specified either in terms of objects or bytes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">target_max_bytes</span> <span class="mi">1000000000000</span>  <span class="c1"># 1 TB</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">target_max_objects</span> <span class="mi">1000000</span>       <span class="c1"># 1 million objects</span>
</pre></div>
</div>
<p>Note that if both limits are specified, Ceph will begin flushing or
evicting when either threshold is triggered.</p>
</div>
<div class="section" id="other-tunables">
<h3>Other tunables<a class="headerlink" href="#other-tunables" title="Permalink to this headline">¶</a></h3>
<p>You can specify a minimum object age before a recently updated object is
flushed to the base tier:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">cache_min_flush_age</span> <span class="mi">600</span>   <span class="c1"># 10 minutes</span>
</pre></div>
</div>
<p>You can specify the minimum age of an object before it will be evicted from
the cache tier:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="n">foo</span><span class="o">-</span><span class="n">hot</span> <span class="n">cache_min_evict_age</span> <span class="mi">1800</span>   <span class="c1"># 30 minutes</span>
</pre></div>
</div>
</div>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../ceph_krb_auth/" class="btn btn-neutral float-right" title="如何配置好 Ceph Kerberos 认证的详细文档" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../bluestore/" class="btn btn-neutral float-left" title="BlueStore Internals" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>